/**
 * 
 */
package net.phoenix.repository.observation;

import java.util.Iterator;
import java.util.List;
import java.util.Vector;

import javax.jcr.observation.Event;
import javax.jcr.observation.EventIterator;

/**
 * @author lixf
 * 
 */
public class EventIteratorWrapper implements EventIterator{
	private int size;
	private int position;
	private Iterator<Event> wrapper;

	public EventIteratorWrapper(Event event) {
		List<Event> events = new Vector<Event>();
		events.add(event);
		this.wrapper = events.iterator();
		this.size = events.size();
		this.position = -1;
	}

	public EventIteratorWrapper(List<Event> events) {
		this.wrapper = events.iterator();
		this.size = events.size();
		this.position = -1;
	}

	@Override
	public void skip(long skipNum) {
		for (int i = 0; i < skipNum; i++)
			wrapper.next();
		this.position += skipNum;
	}

	@Override
	public long getSize() {
		return size;
	}

	@Override
	public long getPosition() {
		return this.position;
	}

	@Override
	public boolean hasNext() {
		return this.wrapper.hasNext();
	}

	@Override
	public Object next() {
		return this.wrapper.next();
	}

	@Override
	public void remove() {
		this.wrapper.remove();
	}

	@Override
	public Event nextEvent() {
		return this.wrapper.next();
	}

}
